﻿CREATE FUNCTION MakeTrackerIDsBatch(
	@StartID varchar(50),
	@Quantity int
)RETURNS @T TABLE (TrackerID varchar(50))
AS BEGIN

DECLARE @I int SET @I = 1

WHILE ISNUMERIC(RIGHT(@StartID,@I)) = 1
	SET @I = @I + 1

IF @I = 1 RETURN

DECLARE @ID varchar(50) SELECT @ID = RIGHT(@StartID,@I-1),@StartID = LEFT(@StartID,LEN(@StartID)-@I+1),@I = 0

WHILE @I < @Quantity BEGIN
	INSERT INTO @T VALUES(@StartID +dbo.FormatFix(@ID+@I,LEN(@ID)))
	SET @I = @I + 1
END

RETURN
END
